#ifndef DRDBSUPPORT_H
#define DRDBSUPPORT_H

#include <QObject>
#include <QList>
#include <QVariant>
#include <QtSql>
#include <QMessageBox>

#include "DRDef.h"

#define  DR_DB_TEXT_TBL    tr("record")
#define  DR_DB_ALERM_TBL   tr("alerm")
#define  DR_DB_GROUP_TBL   tr("group")

class DRDBSupport : public QObject
{
    Q_OBJECT
public:
    explicit DRDBSupport(QObject *parent = 0);

signals:
    void onWolkGroupRsp(QList<QVariant>);
    void onWolkRecordRsp(QList<QVariant>);
    void onSearchGroupRsp(QList<QVariant>);
    void onSearchRecordRsp(QList<QVariant>);
    void onNewGroupRsp(QList<QVariant>);
    void onNewAlermRsp(QList<QVariant>);
    void onNewTextRsp(QList<QVariant>);

public slots:
    void wolkGroupReq();
    void wolkRecordReq(int groupIndex);
    void searchGroupReq(QString text);
    void searchRecordReq(QString text, int groupIndex);
    void newGroupReq(QString text);
    void newAlermReq(QList<QVariant>);
    void newTextReq(QList<QVariant>);
    void deleteTextReq(int index);
    void deleteGroupReq(int index);

private:
    QSqlDatabase dbHandle;

    bool initDB();

    QString dbName;
};

#endif // DRDBSUPPORT_H
